-
Notifications
You must be signed in to change notification settings - Fork 41
add tests to all function #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
gemtechd
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When you throw an error about a function parameter
the user should now exactly what is the problem
modules/ecs6-class/line.js
Outdated
| class Line { | ||
| constructor({ point1 = new Point(), point2 = new Point(), n = undefined, slope = undefined }) { | ||
| if((!(point1 instanceof(Point))) || (!(point2 instanceof Point))){ | ||
| throw new Error("The entered arguments is not valid!") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which parameter one is invalid?
modules/ecs6-class/point.js
Outdated
| class Point { | ||
| constructor({x=0, y=0}={}) { | ||
| if(typeof(x)!=="number"||typeof(y)!=="number"){ | ||
| throw new Error("the function should get number") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the x or the y or both are invalid?
modules/geometry-calculation.js
Outdated
|
|
||
| if (line1.slope === line2.slope) { | ||
| if (line1.n === line2.n) { | ||
| return true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens when the slope or n are not calculated?
| } | ||
|
|
||
| const proxyLine = new Line({ point1: line.point1, point2: point }) | ||
| proxyLine.calculateSlope() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what happens if the line.slope is still undefined?
package.json
Outdated
| "coverage":"npm run test -- --coverage" | ||
| }, | ||
| "dependencies": { | ||
| "jest": "^29.7.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jest shouldn't be in the dependecies section
| let lineTest=new Line({}) | ||
|
|
||
| describe ('ERRORS',()=>{ | ||
| it('Error checker for constructor',()=>{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where are the good tests for the constructor?
| it('should calculate the slop', () => { | ||
| line.calculateSlope() | ||
| expect(line.slope).toBe(1) | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where are the errors for the function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing the tests for the constructor...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Write the tests again
did you understand the purpose of mocks (it's written un your presentation)?
So use them
and test correctly
No description provided.